<?php
# write.php
# writes entries to mysql


 ini_set('error_reporting', E_ALL);  //Turns on Error reporting 

 include 'posting_form.php';  // Includes the form
 include 'mysql.php';


	/* Blog System 
	 Before running, make sure you have a MySQL DB called 'blog' with a table like this in it:
	 CREATE TABLE posts(
	id INT NOT NULL PRIMARY KEY AUTO_INCREMENT ,
	postTitle CHAR( 255 ) ,
	PostDate CHAR( 255 ) ,
	PostAuthor CHAR( 255 ) ,
	PostContent TEXT
	);
	*/



if (isset($_POST['submit'])) {
	echo "Request Submited.<br />";
	
	$name = $_POST['name'];
	$title = $_POST['title'];
	$content = $_POST['content'];
	$time = time();

 $post = mysql_query("INSERT INTO posts (postTitle, postDate, postAuthor, postContent) VALUES ('$title', '$time', '$name', '$content');") or die(mysql_error()); 	
	
	
	if ($post) {
	echo 'Post saved succesfully';
	
	} else
	
	echo "Post not saved.";
}


?>

